package vn.hoasua.util;

import java.io.IOException;

import android.content.Context;
import android.util.Log;

import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;

public class PlayServiceUtil {
	// Do not call this function from the main thread. Otherwise, 
	// an IllegalStateException will be thrown.
	public void getIdThread(Context mContext) throws IllegalStateException, GooglePlayServicesRepairableException {

	  Info adInfo = null;
	  try {
	    adInfo = AdvertisingIdClient.getAdvertisingIdInfo(mContext);

	  } catch (IOException e) {
	    // Unrecoverable error connecting to Google Play services (e.g.,
	    // the old version of the service doesn't support getting AdvertisingId).
	 
	  } catch (GooglePlayServicesNotAvailableException e) {
	    // Google Play services is not available entirely.
	  }
	  final String id = adInfo.getId();
	  final boolean isLAT = adInfo.isLimitAdTrackingEnabled();
	  Log.e("Ad id", id);
	  Log.e("is LAT:",isLAT+"");
	}
}
